package com.example.controller;

import com.example.pojo.Content;
import com.example.service.IContentService;
import com.example.util.R;
import com.example.vo.UserContent;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/contents")
@Api(tags = "分享api接口")
public class ContentController {

    @Autowired
    private IContentService contentService;

    @ApiOperation("查询全部")
    @GetMapping("/all")
    public R<List<UserContent>> getAllUserContents() {
        return R.success("成功",contentService.getAllUserContents());
    }

    @ApiOperation("查询单个")
    @GetMapping("/{id}")
    public R<Content> getContentById(@PathVariable("id") Long contentId) {
        return R.success("成功",contentService.getById(contentId));
    }

}
